/* -----------------------------------------------------------------------
 * Chris Lewis
 * CS 362
 * Assignment 3: unittest4.c test of function isGameOver() in dominion.c
 *
 * unittest4: unittest4.c dominion.o rngs.o
 *      gcc -o unittest4 -g  unittest4.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//If NOISY is set to 0, then only an overall pass/fail will display.
//If NOISY is set to 1, then test information will be displayed as executed.
#define NOISY 1

int main() {
        int seed = 1000;                                                                                //initiate a two player game
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState G;
        int over;

    initializeGame(numPlayer, k, seed, &G);

    printf ("\n\n********* UNIT TEST 4 - isGameOver() ************\n");
    printf ("0 = False, 1 = True\n");

        over = isGameOver(&G);                          //test initialized game
        assert(over == 0);
#if (NOISY == 1)
        printf("New Game -- Game is over?: %d\n", over);
#endif

        G.supplyCount[province] = 0;            //test with no more provinces
        over = isGameOver(&G);                          
        assert(over == 1);
#if (NOISY == 1)
        printf("No more provinces -- Game is over?: %d\n", over);
#endif

        G.supplyCount[province] = 1;
        over = isGameOver(&G);                          //test with returned provinces
        assert(over == 0);
#if (NOISY == 1)
        printf("Provinces left -- Game is over?: %d\n", over);
#endif

        G.supplyCount[1] = 0;                           //test with 2 empty supply piles
        G.supplyCount[5] = 0;
        over = isGameOver(&G);                          
        assert(over == 0);
#if (NOISY == 1)
        printf("2 empty supply piles -- Game is over?: %d\n", over);
#endif

        G.supplyCount[7] = 0;                           //test with 3 total empty supply piles
        over = isGameOver(&G);                          
        assert(over == 1);
#if (NOISY == 1)
        printf("3 empty supply piles -- Game is over?: %d\n", over);
#endif

    printf("All tests passed!\n");

    return 0;
}